<?php

/**
 * Created by PhpStorm.
 * User: heqian
 * Date: 17-7-14
 * Time: 上午11:05
 */
class events
{
    /**
     * @param swoole_server $server
     * @param $fd
     * @param $from_id
     */
    public static function onConnect(swoole_server $server, $fd, $from_id)
    {


    }

    /**
     * @param swoole_server $server
     * @param swoole_websocket_frame $frame
     */
    public static function onMessage(swoole_server $server, swoole_websocket_frame $frame)
    {

    }

    /**
     * @param swoole_server $server
     * @param $fd
     * @param $reactor_id
     * @param $data
     */
    public static function onReceive(swoole_server $server, $fd, $reactor_id, $data)
    {
        var_dump($data);

    }

    /**
     * @param swoole_server $server
     * @param string $data 收到的数据内容,可能是文本或者二进制内容
     * @param array $client_info 客户端信息包括address/port/server_socket 3项数据
     */
    public static function onPacket(swoole_server $server, $data, $client_info)
    {
        var_dump($data);

    }

    /**
     * @param swoole_server $server
     * @param $fd
     * @param $reactorId
     */
    public static function onClose(swoole_server $server, $fd, $reactorId)
    {

    }

    /**
     * @param swoole_http_request $request
     * @param swoole_http_response $response
     */
    public static function onRequest(swoole_http_request $request, swoole_http_response $response)
    {
        $response->end('hello swoole');
    }

    /**
     * @param swoole_websocket_server $svr
     * @param swoole_http_request $req
     */
    public static function onOpen(swoole_websocket_server $svr, swoole_http_request $req)
    {

    }

    /**
     * @param swoole_http_request $request
     * @param swoole_http_response $response
     */
    public static function onHandShake(swoole_http_request $request, swoole_http_response $response)
    {

    }

}